package com.itheima.service.impl;

import com.itheima.mapper.UserMapper;
import com.itheima.pojo.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService {
    //注入mapper对象
    @Autowired
    private UserMapper userMapper;

    /**查询所有用户
     * @return 用户集合
     */
    public List<User> findAllUser() {
        return userMapper.findAllUser();
    }

    /**添加用户
     * @param user
     */
    @Override
    public void saveUser(User user) {
        userMapper.saveUser(user);

        System.out.println(user);
    }

    @Override
    public void batchSaveUser(List<User> userList) {
        userMapper.batchSaveUser(userList);

        String a=null;

        boolean b = a.equals("哈哈");

        for (User user : userList) {
            System.out.println(user);
        }
    }
}
